@extends('admin.base')
@section('title', '子订单列表')
@section('content')
<div class="layui-card">
    <fieldset class="layui-elem-field">
        <div class="layui-field-box">
            <a class="layui-btn-sm" href="{{url('admin/home')}}">首页</a>&raquo;
            <a class="layui-btn-sm" href="{{url('admin/order/index')}}">订单列表</a>&raquo;
            <a class="layui-btn-sm" href="{{url('admin/order/son_order?id='.$list->oid)}}">订单号{{$sn}}</a>&raquo;
            <span class="layui-btn-sm">子订单号{{$list['sn_son']}}详情</span>
        </div>
    </fieldset>
    
    <fieldset class="layui-elem-field">
        <div class="layui-field-box">
            <button class="layui-btn layui-btn-radius layui-btn-primary layui-btn-sm"><a href=""><i class="layui-icon layui-icon-refresh-1" style="font-size: 30px;color:#009688"></i></a></button >
        </div>
    </fieldset>
    <style>
        table tr td.tc,table tr th.tc {
            text-align: center;
        }
    </style>
    <div class="layui-card-body">
        <div class="layui-tab layui-tab-card">
            <ul class="layui-tab-title">
                <li class="layui-this">基本信息</li>
                <li>买家信息</li>
            </ul>
            <div class="layui-tab-content" >
                <div class="layui-tab-item layui-show">
                    {//基本信息}
                    <table class="layui-table" lay-size="sm">
                        <colgroup>
                            <col width="150">
                            <col >
                        </colgroup>
                        <tbody>
                            <tr >
                                <th class="tc"><label style="line-height: 30px;">订单号</label></th>
                                <td>{{$list['sn_son']}}</td>
                            </tr>
                            <tr>
                                <th class="tc"><label style="line-height: 30px;">产品名</label></th>
                                <td>{{$list['shop_name']}}</td>
                            </tr>
                            <tr>
                                <th class="tc"><label style="line-height: 30px;">产品图片</label></th>
                                <td><img src="<?php echo "http://".$_SERVER['HTTP_HOST'].$list['shop_pic'];?>"></td>
                            </tr>
                            <tr>
                                <th class="tc"><label style="line-height: 30px;">单价(下单时)</label></th>
                                <td>{{$list['single_price']}}</td>
                            </tr>
                            <tr>
                                <th class="tc"><label style="line-height: 30px;">规格</label></th>
                                <td>@if($list['shop_attr']) {{$list['shop_attr']}} @else 无规格 @endif</td>
                            </tr>
                            <tr>
                                <th class="tc"><label style="line-height: 30px;">数量</label></th>
                                <td>{{$list['num']}}</td>
                            </tr>
                            <tr>
                                <th class="tc"><label style="line-height: 30px;">总价</label></th>
                                <td>{{$list['all_price']}}</td>
                            </tr>
                            <tr>
                                <th class="tc"><label style="line-height: 30px;">下单时间</label></th>
                                <td>{{$list['created_at']}}</td>
                            </tr>

                        </tbody>
                    </table>
                </div>
                <div class="layui-tab-item">
                    {//买家信息}
                    <table class="layui-table" lay-size="sm">
                        <colgroup>
                            <col width="150">
                            <col >
                        </colgroup>
                        <tbody>
                            <tr >
                                <th class="tc"><label style="line-height: 30px;">收货人</label></th>
                                <td>{{$list['name']}}</td>
                            </tr>
                            <tr >
                                <th class="tc"><label style="line-height: 30px;">收货人手机</label></th>
                                <td>{{$list['phone']}}</td>
                            </tr>
                            <tr >
                                <th class="tc"><label style="line-height: 30px;">收货地址</label></th>
                                <td>{{$list['address']}}</td>
                            </tr>
                            <tr>
                                <th class="tc"><label style="line-height: 30px;">发货状态</label></th>
                                <td>{{$list['state_name']}}</td>
                            </tr>
                            <tr>
                                <th class="tc"><label style="line-height: 30px;">快递公司</label></th>
                                <td>
                                    <input type="text" id="exp_company" autocomplete="off" class="layui-input" maxlength="200" style="width:300px;border-color: #888888;display: inline;" value="{{$list['express_com']}}">
                                </td>
                            </tr>
                            <tr>
                                <th class="tc"><label style="line-height: 30px;">快递单号</label></th>
                                <td>
                                    <input type="text" id="exp_sn" autocomplete="off" class="layui-input" maxlength="200" style="width:300px;border-color: #888888;display: inline;" value="{{$list['express_num']}}">
                                </td>
                            </tr>

                            @if($list['state'] == 1)
                                <tr >
                                    <th class="tc"><label style="line-height: 30px;"></label></th>
                                    <td>
                                        <button class="layui-btn layui-btn-sm" onclick="send('1','{$res.id}');">发货</button>
                                    </td>
                                </tr>
                            @else
                                <tr>
                                    <th class="tc"><label style="line-height: 30px;">发货时间</label></th>
                                    <td>
                                        <input type="text" id="exp_company" autocomplete="off" class="layui-input" maxlength="200" style="width:300px;border-color: #888888;display: inline;" value="{{$list['send_time']}}">
                                    </td>
                                </tr>
                            @endif


                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    layui.use('element',function(){
        var element = layui.element;
    })

    function send(){
        let exp_company = $("#exp_company").val();//快递公司
        let exp_sn = $("#exp_sn").val();//快递单号
        if(exp_company == ''){
            $("#exp_company").css('border-color','red');
            layer.msg('请输入快递公司');
            return false;
        }
        $("#exp_company").css('border-color','#888888');
        if(exp_sn == ''){
            $("#exp_sn").css('border-color','red');
            layer.msg('请输入快递单号');
            return false;
        }
        $("#exp_sn").css('border-color','#888888');
        var id = {{$list['id']}}

        layer.confirm("确认执行此操作？", {
            icon: 3,
            title:'提示框',
            btn: ['确定','取消'] //按钮
        },function(){
            $.ajax({
                url:"/admin/order/send",//请求url
                type:"post",//请求方式
                data:{id:id,exp_company:exp_company,exp_sn:exp_sn},//传输参数
                async:true,//异步请求
                dataType:"json",//返回数据格式
                success:function(data){
                    layer.msg(data.msg);
                    location.href = location.href;
                },
                error:function(){
                    layer.msg("服务器正忙！");
                },
            })
        });
    }
</script>
